const express = require('express')

const app = express()

const path = require('path')
app.use(express.static(path.resolve(__dirname, './public')))

//引入中间件 解析post请求
//{ extended: true }表示深层解析
app.use(express.urlencoded({ extended: true }))
app.post("/login", (req, res) => {
  console.log(req.body);
  if (req.body.username == "123123" && req.body.password == '123') {
    res.send(`<h1>${req.body.username}欢迎登录</h1>`)
  } else {
    res.send("<h1>用户名或密码错误</h1>")
  }
})

app.listen(4399, () => {
  console.log('启动成功 \n---> http://localhost:4399/  \n ----> http://127.0.0.1:4399');
})
